using UnityEngine;

namespace Gj
{
    public class InputKeyHelper : NodeHelper
    {
        public KeyCode code;
        private readonly float clickTime = 0.3f;
        private float time;

        protected override BindDataType bindDataType => BindDataType.String;

        private void LateUpdate()
        {
            if (Input.GetKeyDown(code)) time = Time.time;

            if (time > 0 && Input.GetKeyUp(code) && Time.time < time + clickTime)
            {
                time = 0;
                Click();
            }
        }
    }
}